package com.atguigu.schedule.dao.impl;

import com.atguigu.schedule.dao.BaseDao;
import com.atguigu.schedule.dao.SysUserDao;
import com.atguigu.schedule.pojo.SysUser;

import java.util.List;

/**
 * @author yuezi2048
 * @version 1.0
 */
public class SysUserDaoImpl extends BaseDao implements SysUserDao {
    @Override
    public int addSysUser(SysUser sysUser) {
        String sql = "insert into sys_user values(DEFAULT, ?, ?)";
        return baseUpdate(sql, sysUser.getUsername(), sysUser.getUserPwd());
    }

    @Override
    public SysUser findByUsername(String username) {
        String sql = "SELECT uid, username, user_pwd 'userPwd' FROM sys_user where username = ?";
        List<SysUser> sysUsers = baseQuery(SysUser.class, sql, username);
        if (sysUsers != null && sysUsers.size() > 0) {
            return sysUsers.get(0);
        } else {
            return null;
        }
    }
}
